// SPDX-FileCopyrightText: Copyright 2023 CitruS Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

package com.fanwj.citrus.utils

import android.os.RemoteException
import com.fanwj.citrus.Backend
import com.fanwj.citrus.aidl.IBackend

typealias RomMetadata = IBackend.RomMetadata

object GameMetadata {

    fun getMetadata(path: String, reload: Boolean): IBackend.RomMetadata {
        try {
            return Backend.stub.GameMetadata_getMetadata(path, reload)
                ?: IBackend.RomMetadata()
        } catch (e: RemoteException) {
            Backend.handleException(e)
            return IBackend.RomMetadata()
        }
    }

    fun isValid(path: String): Boolean {
        try {
            return Backend.stub.GameMetadata_isValid(path)
        } catch (e: RemoteException) {
            Backend.handleException(e)
            return false
        }
    }

    fun resetMetadata() {
        try {
            Backend.stub.GameMetadata_resetMetadata()
        } catch (e: RemoteException) {
            Backend.handleException(e)
        }
    }
}